home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Arsenal - The Cutting Edge of Hacking / Hacker's Arsenal - The Cutting Edge of Hacking.iso / texts / misc / unixcom.txt < prev    next >
Encoding:
Text File  |  2001-07-11  |  22.8 KB  |  644 lines

  1.  
  2.                        *** A List Of Some OF The Most Useful UNIX **
  3.      *** Hacking Commands, and Some Hints On Their Usage ***
  4.        
  5. ---------------------------------------------------------------
  6.  
  7.      It is fun and often usefull to create a file that is owned 
  8. by someone else.  On most systems with slack security ie 99% of 
  9. all UNIX systems, this is quite easily done.  The chown command 
  10. will change any of your files to make someone else the owner. 
  11. Format is as follows:
  12.  
  13. chown ownername filelist
  14.  
  15.  Where ownername is the new owner, and filelist is the list of 
  16. files to change.  You must own the file which your are goin to 
  17. change, unless you are a superuser....then u can change ANYTHING!
  18.      chgrp is a similar command which will change the group 
  19. ownership on a file.  If you are going to do both a chown and a 
  20. chgrp on a file, then make sure you do the chgrp first!  Once the 
  21. file is owned by someone else, you cant change nything about it!
  22.  
  23. ---------------------------------------------------------------
  24.  
  25.      Sometimes just seeing who is on the system is a challenge in 
  26. itself.  The best way is to write your own version of who in C, 
  27. but if you can't do that then this may be of some help to you:
  28.  
  29.      who   followed by on or more of the following flags:
  30.  
  31.           -b Displays time sys as last booted.
  32.           -H Precedes output with header.
  33.           -l Lists lines waiting for users to logon.
  34.           -q displays number of users logged on.
  35.           -t displays time sys clock was last changed.
  36.           -T displays the state field (a + indicates it is 
  37. possible to send to terminal, a - means u cannot)
  38.           -u Give a complete listing of those logged on.
  39.  
  40.    **who -HTu is about the best choice for the average user**
  41.  
  42. ##by the way, the list of users logged on is kept in the file 
  43. /etc/utmp.  If you want to write your own personalised version of 
  44. who in C, you now know where to look!###
  45.  
  46. --------------------------------------------------------------- 
  47.  
  48.      When a users state field (see -T flag option for who 
  49. command) says that a user has their message function on, this 
  50. actually means that it is possible to get stuff onto their 
  51. screen.
  52.      Basically, every terminal on the system has a file 
  53. corresponding to it.  These files can be found in the /dev 
  54. directory.  You can to anything to these files, so long as you 
  55. have access -eg you can read them, and write to them, but you 
  56. will notice that they never change in size.  They are called 
  57. character specific files, and are really the link between the 
  58. system and the terminals.  Whatever you put in these files will 
  59. go staright to the terminal it corresponds to.
  60.      Unfortunately, on most systems, when the user logs in, the 
  61. "mesg n" command is issued which turns off write access to that 
  62. terminal, BUT- if you can start cating to that terminal before 
  63. system issues the mesg n command, then you will continue to be 
  64. able to get stuff up on that terminal! This has many varied uses.
  65.  
  66.      Check out the terminal, or terminal software being used.  
  67. Often you will be able to remotely program another users 
  68. terminal, simply by 'cating' a string to a users screen.  You 
  69. might be able to set up a buffer, capturing all that is typed, or 
  70. you may be able to send the terminal into a frenzy- (sometimes a 
  71. user will walk away without realizing that they are sill 
  72. effectively logged on, leaving you with access to their 
  73. account!).  Some terminal types also have this great command 
  74. called transmit screen. It transmits everything on the screen, 
  75. just as if the user had typed it !
  76.      So just say I wanted to log off a user, then I would send a 
  77. clear screen command (usually ctrl l), followed by "exit" 
  78. followed by a carriage return, followed by the transmit screen 
  79. code.  Using ths technique you can wipe peoples directories or 
  80. anything.  My favourite is to set open access on all their files 
  81. and directories so I can peruse them for deletion etc at my own 
  82. leisure).            
  83.  
  84. ---------------------------------------------------------------
  85.  
  86.      If you ever briefly get access to another persons account 
  87. eg. they leave the room to go to toilet or whatever, then simply 
  88. type the following:
  89.  
  90. chmod 777 $HOME
  91. chmod 777 $MAIL
  92.  
  93.      Then clear the screen so they dont see what you just typed.
  94.  
  95.      Now you can go look at their directory, and their mail, and 
  96. you can even put mail in their mail file. (just use the same 
  97. format as any mail that is already there!). Next time they log in 
  98. the system will automatically inform them they have new mail!
  99.  
  100. ---------------------------------------------------------------
  101.  
  102.      Another way to send fake mail to people is to use the mail 
  103. server.  This method produces mail that is slightly different to 
  104. normal, so anyone who uses UNIX a bit may be suspiscious when 
  105. they receive it, but it will fool the average  user!
  106.  
  107. type telnet
  108.  
  109. the following prompt will appear:
  110.  
  111. telnet>
  112.  
  113. now type :
  114.  
  115. open localhost 25
  116.  
  117. some crap will come up about the mail server..now type:
  118.  
  119. mail from: xxxxxx     Put any name you want.
  120.  
  121. some more bullshit will come up. Now type:
  122.  
  123. rcpt to: xxxxxx  Put the name of the person to receive mail here.
  124.  
  125. now type:
  126.  
  127. data
  128.  
  129. now you can type the letter...end it with a "."
  130. type quit to exit once you are done.
  131.  
  132. -------------------------------------------------------------
  133.  
  134.      Heres one for any experimenters out there...
  135. It is possible to create files which simply cannot be deleted 
  136. from the standard shell.  To do this you will have to physically 
  137. CREATE THE FILE USING A C PROGRAM or SCRIPT FILE, and you will 
  138. have to use a sequence of control characters which cannot be 
  139. typed from the shell.  Try things like Ctrl-h (this is the 
  140. code for the delete key).  Just a file with the name Ctrl-h would 
  141. not be deleteable from the shell, unless you used wildcards. So, 
  142. make it a nice long series of characters, so that to delete the 
  143. file, the user has no choice but to individually copy all his 
  144. files elsewhere, then delete everything in his directory, and 
  145. then copy all his files back.....this is one of my 
  146. favourites..gets em every time!
  147.      
  148.      The following script file is an example which will create a 
  149. file with the name Ctrl-h.  You MUST tyoe this file in using the 
  150. vi editor or similar.
  151. *****If you are not very good with vi, type "man vi" and print the 
  152. help file...it even contains stuff that I find useful now and 
  153. then.*****
  154.  
  155. type the following in vi...
  156.  
  157. echo'' > 'a^h'
  158.  
  159.   ***NOTE...to get the ^h (this really means ctrl-h) from vi type:
  160.  
  161. Ctrl v
  162. Ctrl h 
  163.  
  164.   The Ctrl v instrcts vi to take the next character as a ascii 
  165. character, and not to interpret it.
  166.      change the access on the file you just created and now 
  167. execute it.  It will create a file which looks like it is called 
  168. a, but try to delete it !..use wildcards if you really want to 
  169. delete it. 
  170.  
  171. *> Title:   Tutorial on hacking through a UNIX system
  172.  
  173.  
  174. ** 
  175.  
  176. In the following file, all references made to the name Unix, may also be 
  177. substituted to the Xenix operating system. 
  178.  
  179. Brief history:  Back in the early sixties, during the development of 
  180. third generation computers at MIT, a group of programmers studying the 
  181. potential of computers, discovered their ability of performing two or 
  182. more tasks simultaneously.  Bell Labs, taking notice of this discovery, 
  183. provided funds for their developmental scientists to investigate into this 
  184. new frontier.  After about 2 years of developmental research, they produced 
  185. an operating system they called "Unix".  
  186. Sixties to Current:  During this time Bell Systems installed the Unix system 
  187. to provide their computer operators with the ability to multitask so that 
  188. they could become more productive, and efficient.  One of the systems they
  189. put on the Unix system was called "Elmos". Through Elmos many tasks (i.e.
  190. billing,and installation records) could be done by many people using the same 
  191. mainframe. 
  192.  
  193. Note: Cosmos is accessed through the Elmos system. 
  194.  
  195. Current:  Today, with the development of micro computers, such multitasking 
  196. can be achieved by a scaled down version of Unix (but just as 
  197. powerful).  Microsoft,seeing this development, opted to develop their own 
  198. Unix like system for the IBM line of PC/XT's.  Their result they called 
  199. Xenix (pronounced zee-nicks).  Both Unix and Xenix can be easily installed 
  200. on IBM PC's and offer the same function (just 2 different vendors). 
  201.  
  202. Note: Due to the many different versions of Unix (Berkley Unix, 
  203. Bell System III, and System V the most popular) many commands 
  204. following may/may not work. I have written them in System V routines. 
  205. Unix/Xenix operating systems will be considered identical systems below. 
  206.  
  207. How to tell if/if not you are on a Unix system:  Unix systems are quite 
  208. common systems across the country. Their security appears as such: 
  209.  
  210. Login;     (or login;) 
  211. password: 
  212.  
  213. When hacking on a Unix system it is best to use lowercase because the Unix 
  214. system commands are all done in lower- case. Login; is a 1-8 character field. It is 
  215. usually the name (i.e. joe or fred) of the user, or initials (i.e. j.jones 
  216. or f.wilson).  Hints for login names can be found trashing the location of 
  217. the dial-up (use your CN/A to find where the computer is). Password: is a 1-8 character password assigned by the sysop or chosen by the user. 
  218.    
  219.    Common default logins 
  220.    -------------------------- 
  221.    login;       Password: 
  222.    root         root,system,etc.. 
  223.    sys          sys,system 
  224.    daemon       daemon 
  225.    uucp         uucp 
  226.    tty          tty 
  227.    test         test 
  228.    unix         unix 
  229.    bin          bin 
  230.    adm          adm 
  231.    who          who 
  232.    learn        learn 
  233.    uuhost       uuhost 
  234.    nuucp        nuucp 
  235.  
  236. If you guess a login name and you are not asked for a password, and have 
  237. accessed to the system, then you have what is known as a non-gifted account. 
  238. If you guess a correct login and pass- word, then you have a user account. 
  239. And, if you get the root p/w you have a "super-user" account. 
  240. All Unix systems have the following installed to their system: 
  241. root, sys, bin, daemon, uucp, adm Once you are in the system, you will 
  242. get a prompt. Common prompts are: 
  243.  
  244.  
  245. But can be just about anything the sysop or user wants it to be. 
  246.  
  247. Things to do when you are in: Some of the commands that you may want to 
  248. try follow below: 
  249.  
  250. who is on  (shows who is currently logged on the system.) 
  251. write name (name is the person you wish to chat with) 
  252. To exit chat mode try ctrl-D. 
  253. EOT=End of Transfer. 
  254. ls -a      (list all files in current   directory.) 
  255. du -a      (checks amount of memory  your files use;disk usage) 
  256. cd\name    (name is the name of the sub-directory you choose) 
  257. cd\        (brings your home directory  to current use) 
  258. cat name   (name is a filename either  a program or documentation  your username has written) 
  259.  Most Unix programs are written  in the C language or Pascal 
  260.  since Unix is a programmers'  environment. One of the first things done on the 
  261. system is print up or capture (in a buffer) the file containing all user names and accounts. This can be done by doing the following command: 
  262.  
  263. cat /etc/passwd 
  264.  
  265. If you are successful you will see a list of all accounts on the system.  It 
  266. should look like this:  
  267. root:hvnsdcf:0:0:root dir:/: joe:majdnfd:1:1:Joe Cool:/bin:/bin/joe hal::1:2:Hal Smith:/bin:/bin/hal 
  268.  
  269. The "root" line tells the following info : 
  270. login name=root 
  271. hvnsdcf   = encrypted password 
  272. 0         = user group number 
  273. 0         = user number 
  274. root dir  = name of user 
  275. /         = root directory 
  276.  
  277. In the Joe login, the last part "/bin/joe " tells us which directory 
  278. is his home directory (joe) is. In the "hal" example the login name is 
  279. followed by 2 colons, that means that there is no password needed to get in 
  280. using his name. 
  281.  
  282. Conclusion:  I hope that this file will help other novice Unix hackers 
  283. obtain access to the Unix/Xenix systems that they may find.
  284.  
  285.  
  286.  
  287.                       On the Security of UNIX
  288.  
  289.                       =-=-=-=-=-=-=-=-=-=-=-=
  290.  
  291. Recently there has been much interest in the security aspects of operating
  292.  
  293. systems and software.At issue is the ability to prevent undesired disclosure of
  294.  
  295. information, destruction of information,and harm to the functioning of the
  296.  
  297. system.This paper discusses the degree of security which can be provided under
  298.  
  299. the system and offers a number of hints on how to improve security.The first
  300.  
  301. fact to face is that UNIX was not developed with security,in any realistic
  302.  
  303. sense,in mind;this fact alone guarantees a vast number of holes.(Actually the
  304.  
  305. same statement can be made with respect to most systems.)
  306.  
  307.  
  308.  
  309. The area of security in which is theoretically weakest is in protecting against
  310.  
  311. crashing or at least crippling the operation of the system.The problem here is
  312.  
  313. not mainly in uncritical acceptance of bad parameters to system calls (there
  314.  
  315. may be bugs in this area, but none are known)but rather in lack of checks for
  316.  
  317. excessive consumption of resources.
  318.  
  319.  
  320.  
  321. Most notably, there is no limit on the amount of disk storage used, either in
  322.  
  323. total space allocated or in the number of files or directories.Here is a
  324.  
  325. particularly ghastly shell sequence guaranteed to stop the system:
  326.  
  327.  
  328.  
  329.  
  330.  
  331. while : ; do
  332.  
  333.         mkdir x
  334.  
  335.         cd x
  336.  
  337. done
  338.  
  339.  
  340.  
  341. Either a panic will occur because all the i-nodes on the device are used up,
  342.  
  343. or all the disk blocks will be consumed, thus preventing anyone from writing
  344.  
  345. files on the device.In this version of the system,users are prevented from
  346.  
  347. creating more than a set number of processes simultaneously,so unless users
  348.  
  349. are in collusion it is unlikely that any one can stop the system altogether.
  350.  
  351.  
  352.  
  353. However, creation of 20 or so CPU or disk-bound jobs leaves few resources
  354.  
  355. available for others.Also, if many large jobs are run simultaneously,swap space
  356.  
  357. may run out, causing a panic.  It should be evident that excessive consumption
  358.  
  359. of diskspace, files, swap space and processes can easily occur accidentally in
  360.  
  361. malfunctioning programs as well as at command level.In fact UNIX is essentially
  362.  
  363. defenseless against this kind of abuse,nor is there any easy fix.The best that
  364.  
  365. can be said is that it is generally fairly easy to detect what has happened
  366.  
  367. when disaster strikes ,to identify the user responsible, and take appropriate
  368.  
  369. action.In practice,we have found that difficulties in this area are rather
  370.  
  371. rare,but we have not been faced with malicious users,and enjoy a fairly
  372.  
  373. generous supply of resources which have served to cushion us against accidental
  374.  
  375. overconsumption.
  376.  
  377.  
  378.  
  379. The picture is considerably brighter in the area of protection of information
  380.  
  381. from unauthorized perusal and destruction.Here the degree of security seems
  382.  
  383. (almost) adequate theoretically, and the problems lie more in the necessity for
  384.  
  385. care in the actual use of the system.Each UNIX file has associated with it
  386.  
  387. eleven bits of protection information together with a user identification
  388.  
  389. number and a user-group identification number (UID and GID).
  390.  
  391.  
  392.  
  393. Nine of the protection bits are used to specify independently permission to
  394.  
  395. read, to write, and to execute the file to the user himself, to members of the
  396.  
  397. user's group, and to all other users.Each process generated by or for a user
  398.  
  399. has associated with it an effective UID and a real UID, and an effective and
  400.  
  401. real GID.When an attempt is made to access the file for reading, writing, or
  402.  
  403. executing UID for the process is changed to the UID associated with the file;
  404.  
  405. the change persists until the process terminates or until the UID changed again
  406.  
  407. by another execution of a set-UID file.Similarly the effective group ID of a
  408.  
  409. process is changed to the GID associated with a file when that file is executed
  410.  
  411. and has the set-GID bit set.The real UID and GID of a process do not change
  412.  
  413. when any file is executed,but only as the result of a privileged system
  414.  
  415. call.The basic notion of the set-UID and set-GID bits is that one may write a
  416.  
  417. program which is executableby others and which maintains files accessible to
  418.  
  419. others only by that program.
  420.  
  421.  
  422.  
  423. The classical example is the game-playing program which maintains records of
  424.  
  425. the scores of its players.The program itself has to read and write the score
  426.  
  427. file,but no one but the game's sponsor can be allowed unrestricted access to
  428.  
  429. the file lest they manipulate the game to their own advantage.
  430.  
  431.  
  432.  
  433. The solution is to turn on the set-UID bit of the game program.  When, and only
  434.  
  435. when,it is invoked by players of the game,it may update the score file but
  436.  
  437. ordinary programs executed by others cannot access the score.  There are a
  438.  
  439. number of special cases involved in determining access permissions.  Since
  440.  
  441. executing a directory as a program is a meaningless operation,the
  442.  
  443. execute-permission bit, for directories, is taken instead to mean permission to
  444.  
  445. search the directory for a given file during the scanning of a path name; thus
  446.  
  447. if a directory has execute permission but no read permission for a given user,
  448.  
  449. he may access files with known names in the directory,but may not read (list)
  450.  
  451. the entire contents of the directory.
  452.  
  453.  
  454.  
  455. Write permission on a directory is interpreted to mean that the user may create
  456.  
  457. and delete files in that directory;it is impossible for any user to write
  458.  
  459. directly into any directory..Another, and from the point of view of security,
  460.  
  461. much more serious special case is that there is a ``super user'' who is able to
  462.  
  463. read any file and write any non-directory.The super-user is also able to change
  464.  
  465. the protection mode and the owner UID and GID of any file and to invoke
  466.  
  467. privileged system calls.It must be recognized that the mere notion of a
  468.  
  469. super-user is a theoretical, and usually practical, blemish on any protection
  470.  
  471. scheme.
  472.  
  473.  
  474.  
  475. The first necessity for a secure system is of course arranging that all files
  476.  
  477. and directories have the proper protection modes.Traditionally, UNIX software
  478.  
  479. has been exceedingly permissive in this regard;essentially all commands create
  480.  
  481. files readable and writable by everyone.In the current version,this policy may
  482.  
  483. be easily adjusted to suit the needs ofthe installation or the individual user.
  484.  
  485.  
  486.  
  487. Associated with each process and its descendants is a mask, which is in effect
  488.  
  489. anded with the mode of every file and directory created by that process.  In
  490.  
  491. this way, users can arrange that, by default,all their files are no more
  492.  
  493. accessible than they wish.The standard mask, set by login,allows all permiss-
  494.  
  495. ions to the user himself and to his group,but disallows writing by others.
  496.  
  497.  
  498.  
  499. To maintain both data privacy and data integrity,it is necessary, and largely
  500.  
  501. sufficient,to make one's files inaccessible to others.  The lack of sufficiency
  502.  
  503. could follow from the existence of set-UID programs created by the user and the
  504.  
  505. possibility of total breach of system security in one of the ways discussed
  506.  
  507. below(or one of the ways not discussed below).
  508.  
  509.  
  510.  
  511. For greater protection,an encryption scheme is available.Since the editor is
  512.  
  513. able to create encrypted documents, and the crypt command can be used to pipe
  514.  
  515. such documents into the other text-processing programs,the length of time
  516.  
  517. during which clear text versions need be available is strictly limited.The
  518.  
  519. encryption scheme used is not one of the strongest known, but it is judged
  520.  
  521. adequate, in the sense that cryptanalysisis likely to require considerably more
  522.  
  523. effort than more direct methods of reading the encrypted files.For example, a
  524.  
  525. user who stores data that he regards as truly secret should be aware that he is
  526.  
  527. implicitly trusting the system administrator not to install a version of the
  528.  
  529. crypt command that stores every typed password in a file.  Needless to say, the
  530.  
  531. system administrators must be at least as careful as their most demanding user
  532.  
  533. to place the correct protection mode on the files under their control.
  534.  
  535.  
  536.  
  537. In particular,it is necessary that special files be protected from writing, and
  538.  
  539. probably reading, by ordinary users when they store sensitive files belonging
  540.  
  541. to otherusers.It is easy to write programs that examine and change files by
  542.  
  543. accessing the device on which the files live.
  544.  
  545.  
  546.  
  547. On the issue of password security,UNIX is probably better than most systems.
  548.  
  549. Passwords are stored in an encrypted form which, in the absence of serious
  550.  
  551. attention from specialists in the field,appears reasonably secure, provided its
  552.  
  553. limitations are understood.In the current version, it is based on a slightl y
  554.  
  555. defective version of the Federal DES;it is purposely defective so that
  556.  
  557. easily-available hardware is useless for attempts at exhaustive
  558.  
  559. key-search.Since both the encryption algorithm and the encrypted passwords are
  560.  
  561. available,exhaustive enumeration of potential passwords is still feasible up to
  562.  
  563. a point.We have observed that users choose passwords that are easy to
  564.  
  565. guess:they are short, or from a limited alphabet, or in a dictionary.
  566.  
  567. Passwords should be at least six characters long and randomly chosen from an
  568.  
  569. alphabet which includes digits and special characters.
  570.  
  571.  
  572.  
  573. Of course there also exist feasible non-cryptanalytic ways of finding out
  574.  
  575. passwords.For example:  write a program which types out ``login:''on the
  576.  
  577. typewriter and copies whatever is typed to a file of your own.  Then invoke the
  578.  
  579. command and go away until the victim arrives..The set-UID (set-GID)notion must
  580.  
  581. be used carefully if any security is to be maintained.  The first thing to keep
  582.  
  583. in mind is that a writable set-UID file can have another program copied onto
  584.  
  585. it.
  586.  
  587.  
  588.  
  589. For example, if the super-user command is writable,anyone can copy the shell
  590.  
  591. onto it and get a password-free version of Shell Unix.A more subtle problem can
  592.  
  593. come from set-UID programs which are not sufficiently careful of what is fed
  594.  
  595. into them.To take an obsolete example,the previous version of the mail command
  596.  
  597. was set-UID and owned by the super-user.This version sent mail to the r
  598.  
  599. ecipient's own directory.The notion was that one should be able to send mail to
  600.  
  601. anyone even if they want to protecttheir directories from writing.  The trouble
  602.  
  603. was that mailwas rather dumb:anyone could mail someone else's priva te file to
  604.  
  605. himself.Much more seriousis the following scenario:  make a file with a line
  606.  
  607. like one in the password filewhich allows one to log in as the super-user.Then
  608.  
  609. make a link named ``.mail'' to the password file in some writable directory on
  610.  
  611. the same device as the password file (say /tmp).  Finally mail the bogus login
  612.  
  613. line to /tmp/.mail;You can then login as the superuser,clean up the
  614.  
  615. incriminating evidence,and have your will.
  616.  
  617.  
  618.  
  619. The fact that users can mount their own disks and tapes as file systems can be
  620.  
  621. another way of gaining super-user status.Once a disk pack is mounted, the
  622.  
  623. system believes what is on it.Thus one can take a blank disk pack,put on it
  624.  
  625. anything desired,and mount it.There are obvious and unfortunate consequences.
  626.  
  627. For example:a mounted disk with garbage on it will crash the system;one of the
  628.  
  629. files on the mounted disk can easily be a password-free version of Shell Unix;
  630.  
  631. other files can be unprotected entries for special files.  The only easy fix
  632.  
  633. for this problem is to forbid the use of mount to unpriv- ileged users.A
  634.  
  635. partial solution, not so restrictive,would be to have the mount command examine
  636.  
  637. the special file for bad data,set-UID programs owned by others ,and accessible
  638.  
  639. special files,and balk at unprivileged invokers.
  640.  
  641.